<?php defined('SYSPATH') or die('No direct script access.');
class Controller_DefaultTemplate extends Controller_Template
{
	public $template = 'defaults/default';

	/**
	 * Initialize properties before running the controller methods (actions),
	 * so they are available to our action.
	 */
	public function before() {
		parent::before();
		
		$GLOBALS['json_connected'] = True;
		
		if($this->auto_render) {
			$this->template->title            = '';
			$this->template->meta_keywords    = '';
			$this->template->meta_description = '';
			$this->template->meta_copywrite   = '';
			$this->template->script			  = '';
			$this->template->header           = '';
			$this->template->content          = '';
			$this->template->menu     		  = '';
			$this->template->footer           = '';
			$this->template->filters		  = '';
			$this->template->chartOptions	  = '';
			$this->template->pageTitle        = 'This is the default page title';
			$this->template->styles           = array();
			$this->template->scripts          = array();
			
			$chartOptions					= new View('defaults/chartOptions.php');
			$this->template->chartOptions	= $chartOptions;
			$this->template->chartOptions->select1MinVal 	= 3;
			$this->template->chartOptions->select1MaxVal 	= 11;
			$this->template->chartOptions->select1			= 7;
			$this->template->chartOptions->select2			= "dag";
			$this->template->chartOptions->select2Options	= array("minuut", "uur", "dag", "week", "maand", "jaar");
			
			$this->template->keywords						= array();
		}
	}

	/**
	 * Fill in default values for our properties before rendering the output.
	 */
	public function after()	{
		if($this->auto_render)
		{
			$styles                  		= array('assets/css/style.css' => 'screen');
			$scripts                 		= array('assets/js/js.js', 'https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js');

			$header							= new View('defaults/header.php');
			$footer							= new View('defaults/footer.php');
			$menu							= new View('defaults/menu.php');
			$filters						= new View('defaults/filters.php');
			
			if (isset($_GET['keywords'])) {
				$keywords 					= explode(' ', $_GET['keywords']);
			}
			
			$filters->bind('keywords', $keywords);

			$this->template->header			= $header;
			$this->template->footer			= $footer;
			$this->template->menu			= $menu;
			$this->template->filters		= $filters;
			

			$this->template->styles   		= array_reverse(array_merge($this->template->styles, $styles));
			$this->template->scripts   		= array_reverse(array_merge($this->template->scripts, $scripts));
		}

		parent::after();
	}
}